<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<%include("/common/include.html"){}%>
		<style type="text/css">
			
		</style>
	</head>
		<body style="overflow-x:hidden">
		<form id="zxcsform" action="${cxt !}/collection/measurement/cesuan" method="post">
		<input id="serviceIds" name="serviceIds"     type="hidden"  value="${serviceIds !}">
		<div style="width: 90%">
			<%include("/collection/binShopService/collectionSearchCustomer1.html"){}%>
		</div>
		<div  id="mbtablediv" class="easyui-panel"  style="height:auto;padding:5px;margin-top: 15px" align="center" >
				<table   id="mbtable" border="1"  bordercolor="#DDDDDD" style="width:100%;height:85%; text-align: center;font-size: 15px;">
										<tr style="font-weight: bold;">
										<!-- <td rowspan="2" style="width:4%;">姓名</td> -->
										<td rowspan="2" style="width:5%;">体重</td>
										<!-- <td rowspan="2" style="width:20%;height: 30px;">到店时间</td>
										<td rowspan="2" style="width:20%;height: 30px;">结束时间</td> -->
										<td rowspan="2" style="width:3%;">能量膏</td>
										
										<!-- <td colspan="3" >减重情况</td> -->
										<td rowspan="2" style="width:5%;height: 30px;">手法</td>
										<%if(partnum == 8){%>
										<td colspan="8" >精护部位</td>
										<%}else if(partnum == 7){%>
										<td colspan="7" >精护部位</td>
										<%}else if(partnum == 5){%>
										<td colspan="5" >精护部位</td>
										<%}else if(partnum == 4){%>
										<td colspan="4" >精护部位</td>
										<%}else{%>
										<td colspan="6" >精护部位</td>
										<%}%>
										<!-- <td colspan="8" >精护部位</td> -->
										<td rowspan="2" style="width:20%;height: 30px;">备注</td>
										</tr>
										
										<tr >
										
										<td style="width:5%;height: 30px;">腰部</td>
										<td style="width:5%;height: 30px;">大腿</td>
										<td style="width:5%;height: 30px;">小腿</td>
										<td style="width:5%;height: 30px;">胳膊</td>
										<%if(bbExp=='1'){%>
											<td style="width:8%;height: 30px;">背部</td>
										<%}%>
										<%if(kbExp=='1'){%>
										<td style="width:8%;height: 30px;">胯部</td>
										<%}%>
										<%if(Exp=='1'){%>
										<td style="width:8%;height: 30px;">左副乳</td>
										<td style="width:8%;height: 30px;">右副乳</td>
										<%}%>
										</tr>
										
										
										<tr style="font-weight: bold;">
										<!-- <td  style="width:5%;">
											<input class="easyui-combobox" name="language" style="width: 90%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; " id="customerName" name="customer.name"  value="${customerName !}"  
										data-options="
										url:'${cxt!}/bentryRegister/getCusInfo',
										method:'post',
										valueField:'name',
										textField:'name'
										">
										</td> -->
										
										<td  style="width:5%;">
											<input id = "weight" class="easyui-numberspinner inputBox theme-textbox-radius" required="true" data-options="increment:0.1,min:50,max:400,precision:1" name="weight" style="width: 70px;height: 30px;" >
										</td>
										<!-- <td  style="width:10%;">
											<input class="easyui-datetimebox theme-textbox-radius" name="customerService.weight" value="${customerService.weight!}"  id="weight" style="width: 90%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  >
										</td>
										<td  style="width:10%;">
											<input class="easyui-datetimebox theme-textbox-radius" name="customerService.weight" value="${customerService.weight!}"  id="weight" style="width: 90%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  >
										</td> -->
										<td  style="width:5%;">
										<input id = "yt" class="easyui-numberspinner inputBox theme-textbox-radius" required="true" data-options="increment:1,min:0,max:1" name="ytstr"  value="1"  style="width: 50px;height: 30px;">
										</td>
										
										<td  style="width:5%;height: 30px;">
										<#organization type="select" id="sf" name="sf"   organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius" style="width: 80px;height: 30px;"/>
										</td>
										
										
										<td  style="width:18%;height: 30px;" id="ybtd">
										<#organization type="select" id="ybUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width:80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}" id="yb"   style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"   style="width: 60px;height: 30px;" onclick="savesfInfo('','yb','')">用量</a>
										</td>
										
										
										<td  style="width:18%;height: 30px;" id=" dttd">
										<#organization type="select" id="dtUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width: 80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"  id=" dt" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','dt','')">用量</a>
										</td>
										
										<td  style="width:18%;height: 30px;" id=" xttd">
										<#organization type="select" id="xtUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width: 80px;height: 30px;"/>
<!-- 										<input class="easyui-validatebox"  type="password" value="${temporary.height !}"  id=" xt"  style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','xt','')" >用量</a>
										</td>
										
										<td  style="width:18%;height: 30px;" id=" gbtd">
										<#organization type="select" id="gbUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width:80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"   id=" gb" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton" style="width: 60px;height: 30px;" onclick="savesfInfo('','gb','')" >用量</a>
										</td>
									
										
										
										
										<%if(bbExp=='1'){%>
										<td  style="width:18%;height: 30px;" id=" bbtd">
										<#organization type="select" id="bbUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width: 80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"   id=" bb" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','bb','')" >用量</a>
										</td>	
										<%}%>
										
										
										
									
										<%if(kbExp=='1'){%>
										<td  style="width:18%;height: 30px;" id=" kbtd">
										<#organization type="select" id="kbUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width: 80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"   id=" kb" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','kb','')" >用量</a>
										</td>
										<%}%>
										
										<%if(Exp=='1'){%>
										<td  style="width:18%;height: 30px;" id=" zfrtd">
										<#organization type="select" id="zfrUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width: 80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"   id=" zfr" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','zfr','')" >用量</a>
										
										</td>
										<td  style="width:18%;height: 30px;" id="yfrtd">
										<#organization type="select" id="yfrUser"  organization="${organids! }" defaultCode="${customerService.plasterservier!}"   class="easyui-combobox inputBox theme-textbox-radius"  style="width:80px;height: 30px;"/>
										<!-- <input class="easyui-validatebox"  type="password" value="${temporary.height !}"   id=" yfr" style="width: 50%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  > -->
										<a href="#" class="easyui-linkbutton"  style="width: 60px;height: 30px;" onclick="savesfInfo('','yfr','')" >用量</a>
										<%}%>
										
										<td >
										<input     type="text" value="${customerService.bz!}"   id="bz"   name="customerService.bz"        style="width: 90%;height: 30px;margin: 0px;padding: 0px;border-radius:3px;  border: 1px solid #ff7e00; "  >
										</td>
										</tr>
										<tr align="center">
										<td   colspan="11">
			
										<a href="#" class="easyui-linkbutton"  style="width:10%;height: 30px;font-weight: bold;border: 1px solid #9acd00;" onclick="deleterow()">保存</a>
										</td>
										</tr>
					</table>					
		</div>
		
		
		
		<script>
		
		$(document).ready(function () {
			
			var flag = $("#flag").val();
			if(flag=='1'){
				 parent.window.nodeClick("正在服务", "/beingServed");
			}
			
			
			$("#date_input").datebox({

				onChange: function (n,o) {

					$("#customerName").textbox("clear");
					$("#customerPhone").textbox("clear");
					$("#customerHybh").textbox("clear");
					$("#gbUser").textbox("clear");
					$("#dtUser").textbox("clear");
					$("#xtUser").textbox("clear");
					$("#ybUser").textbox("clear");
					$("#kbUser").textbox("clear");
					$("#zfrUser").textbox("clear");
					$("#yfrUser").textbox("clear");
					$("#bbUser").textbox("clear");
					$("#weight").textbox("clear");
					$("#sf").textbox("clear");
					//$("#plasterCount").textbox('setValue',"1");
					/* $("#zc").html("");
					$("#dc").html(""); */
					$("#bz").textbox('setValue',"");
					searchCus();
				}

				});
			
			

		
			
			
			
			$("#customerName").combobox({

			onChange: function (n,o) {
	
				$("#sf").textbox("clear");
				$("#customerPhone").textbox("clear");
				$("#customerHybh").textbox("clear");
				$("#weight").textbox("clear");
				$("#gbUser").textbox("clear");
				$("#dtUser").textbox("clear");
				$("#xtUser").textbox("clear");
				$("#ybUser").textbox("clear");
				$("#kbUser").textbox("clear");
				$("#zfrUser").textbox("clear");
				$("#yfrUser").textbox("clear");
				$("#bbUser").textbox("clear");
				//$("#plasterCount").textbox('setValue',"1");
				/* $("#zc").html("");
				$("#dc").html(""); */
				$("#bz").val("");
				searchCus();
			}

			});
			$("#customerPhone").combobox({

				onChange: function (n,o) {

					$("#customerName").textbox("clear");
					$("#customerHybh").textbox("clear");
					$("#sf").textbox("clear");
					$("#gbUser").textbox("clear");
					$("#dtUser").textbox("clear");
					$("#xtUser").textbox("clear");
					$("#ybUser").textbox("clear");
					$("#kbUser").textbox("clear");
					$("#zfrUser").textbox("clear");
					$("#yfrUser").textbox("clear");
					$("#bbUser").textbox("clear");
					$("#weight").textbox("clear");
					//$("#plasterCount").textbox('setValue',"1");
					/* $("#zc").html("");
					$("#dc").html(""); */
					$("#bz").val("");
					searchCus();
				}

				});
			$("#customerHybh").combobox({

				onChange: function (n,o) {

					$("#customerName").textbox("clear");
					$("#customerPhone").textbox("clear");
					$("#sf").textbox("clear");
					$("#gbUser").textbox("clear");
					$("#dtUser").textbox("clear");
					$("#xtUser").textbox("clear");
					$("#ybUser").textbox("clear");
					$("#kbUser").textbox("clear");
					$("#zfrUser").textbox("clear");
					$("#yfrUser").textbox("clear");
					$("#bbUser").textbox("clear");
					$("#weight").textbox("clear");
					/* $("#plasterCount").textbox('setValue',"1");
					$("#zc").html("");
					$("#dc").html(""); */
					$("#bz").val("");
					searchCus();
				}

				});
			
		
		});
		
		

		//清除筛选条件
		function clearsj(){
			$("#customerName").textbox("clear");
			$("#customerPhone").textbox("clear");
			$("#customerHybh").textbox("clear");
			$("#cpbh").textbox("clear");
			$('#cpbh').textbox('textbox').attr('readonly',false);
			
		}
		function searchCus(){
			var hybh=$('#customerHybh').val();
			var name=$('#customerName').val();
			var phone=$('#customerPhone').val();
			//var date = $('#starttime').textbox('getValue');
			var date=$('#date_input_start').val();
			//alert(date);
			if(date==''){
				return false;
			}
			if(hybh==''&&name==''&&phone==''){
				return false;
			}
			var url='/binShopOutController/getCusByHybh';
			var data={"hybh":hybh,"name":name,"phone":phone,"starttime":date};
			var reData = common_ajax.ajaxFunc(url,data,"json");
			if(reData.msg==200){
				$("#customerIds").val(reData.customer.ids);
				$("#customerName").textbox('setValue',reData.customer.name);
				$("#customerPhone").textbox('setValue',reData.customer.phone);
				$("#customerHybh").textbox('setValue',reData.customer.hybh);
				
				/* $("#sf").textbox('setValue',reData.customerService.sf);
				$("#yb").textbox('setValue',reData.customerService.yb);
				$("#dt").textbox('setValue',reData.customerService.dt);
				$("#xt").textbox('setValue',reData.customerService.xt);
				$("#gb").textbox('setValue',reData.customerService.gb); */
				
				//$("#weight").val(reData.customerService.weight);
				/* $("#plasterCount").textbox('setValue',reData.customerService.plastercount); */
				/* var tzc = (reData.customerService.weight-reData.customerService.lastweight).toFixed(2);
				
				if(tzc>0){
					$("#zc").html(tzc);
				}
				if(tzc<0){
					$("#dc").html(tzc*-1);
				} */
				//$("#bz").val(reData.customerService.bz);
				
			}else if( reData.msg== "该顾客当天已经存在服务记录，不能添加"){
				$.alert(parent.$,reData.msg);
			}
				
		}


		
		function savesfInfo(id,bw,sid){
			var customerIds = $("#customerIds").val();
			var serviceIds =  $("#serviceIds").val();
			var date=$('#date_input_start').val();
			var endtime=$('#date_input_end').val();
			var userstr = bw+'User';
			var user = $("#"+userstr).val();
			
			if(user=='-1'){
				$.alert(parent.$, "请选择该部位服务人员！");
				return false;
			}
			if(date==""||endtime==""){
				$.alert(parent.$,"请选择开始时间和结束时间");
				return false;
			}
			if(customerIds==""){
				$.alert(parent.$,"请选择顾客");
				return false;
			}
			
			if(bw=='sf'){
				var strid = id+'sf';
				var sf = $("#"+strid).val();
				if(sf!=null&&sf.length!=2){
					$.alert(parent.$, "验证码不能为空！");
					return false
				}
					
				
				var url='/beingServed/updateSer';
				
				
				var data={"cid":customerIds,"sf":sf,"sid":serviceIds,"date":date};
				var reData = common_ajax.ajaxFunc(url,data,"json");
				if(reData.msg==true){
					
					var strtdid = id+'sftd';
					$("#"+strtdid).html(reData.user.name);
					
				}else{
					$.alert(parent.$, reData.msg);
				}
			}
			if(bw!=null&&bw!='sf'){
				var strid = id+bw;
				var sf = $("#"+strid).val();
				if(sf!=null&&sf.length!=2){
					$.alert(parent.$, "验证码不能为空！");
					return false
				}
				
				loadDialog($("#mbtablediv"), null, '客户产品', "${cxt!}/binShopOutController/getCustomerProduct?bw="+bw+"&cid="+customerIds+"&sid="+serviceIds+"&mima="+sf+"&date="+date+"&user="+user);
			}
		}
	
		
	
		
		function deleterow(){
			var customerIds = $("#customerIds").val();
			var serviceIds =  $("#serviceIds").val();
			var date=$('#date_input_start').val();
			var endtime=$('#date_input_end').val();
			var sfuser =$('#sf').val(); 
			if(date==""||endtime==""){
				$.alert(parent.$,"请选择开始时间和结束时间");
				return false;
			}
			if(customerIds==""){
				$.alert(parent.$,"请选择顾客");
				return false;
			}
			var weight=$('#weight').val();
			if(weight == ""){
				$.alert(parent.$,"请输入体重");
				return false;
			}
			var strid = customerIds+'yt';
			var sf = $("#yt").val();
			
			if(sf!=null&&sf<=-1){
				$.alert(parent.$, "能量膏格式错误！");
				return false;
			}
			if(sf!=null&&sf>1){
				$.alert(parent.$, "能量膏格式错误！");
				return false;
			}
			if(sf==null){
				sf="0";
			} 
			parent.$.messager.confirm('提示','结束服务吗？',function(r){
				if (r){
					
					var url = "${cxt!}/binShopOutController/updateSer";
					var data={"cid":customerIds,"yt":sf,"sid":serviceIds,"date":date,"weight":weight,"endtime":endtime,"sf":sfuser};
					$.post(url, data, function(result) {
						
						if (result.msg==true) {
							//parent.window.nodeClick("正在服务", "/beingServed");
							 $.slideMsg("保存成功", parent.$);
							 location.reload();
						} else {
							$.alert(parent.$,result.msg);
						}
					}, 'json');
				}
			});
			
			
		}
			
			
		
		
		
		
		
			$(document).ready(function () {
				var hybh=$('#customerHybh').val();
				var name=$('#customerName').val();
				var phone=$('#customerPhone').val();
				var url='/bentryRegister/getCusByHybh';
				var data={"hybh":hybh,"name":name,"phone":phone};
				var reData = common_ajax.ajaxFunc(url,data,"json");
				if(reData.msg==200){
					$("#customerIds").val(reData.customer.ids);
					$("#customerName").textbox('setValue',reData.customer.name);
					$("#customerPhone").textbox('setValue',reData.customer.phone);
					$("#customerHybh").textbox('setValue',reData.customer.hybh);
				}
			});
			function saveBz(customerid,sid){
				
				var bz=$("#"+customerid+"bz").val();
				if(bz!=null){
					var data={"bz":bz,"ids":sid};
					$.post('${cxt! }/beingServed/saveBz', data,function(result) {
						if(result.status == "200"){
							 $.slideMsg("保存成功", parent.$);
							 $dialog.dialog('destroy');
						}else{
						 $.slideMsg("保存失败", parent.$);
						}
					}, "json");
				}
				
				
			}
			function lookBz(customerid,sid){
				loadViewDialog( '客户产品', "${cxt!}/beingServed/lookBz?ids="+sid+"&yz=2",null,'600','350');
			}

			function loadDialog2(grid, tree, name, url, width, height) {
				if(!width){
					width = 920;
				}
				if(!height){
					height = $(window).height() * 0.9;
				}
				// 弹出窗口
			 	var dialog = parent.sy.modalDialog({
			 		iconCls: 'icon-save',
			        cls:'theme-panel-orange',
			 		title : name,
			 		url : url},width, height);
			}
		
		
		</script>
		</form>
	</body>
</html>

